package game;

import java.util.Random;

public class TTTMoveObtainerImplementor implements MoveObtainerImplementor
{
	public TTTMoveObtainerImplementor()
	{
		itsRowGenerator = new Random();
		itsColumnGenerator = new Random();
	}

	@Override
	public Move obtainInteractiveMove(Player player)
	{
		return null;
	}

	@Override
	public Move obtainSimulationMove(Board board, Player player)
	{
		int row, column;
		
		while(true)
		{
			row		= itsRowGenerator.nextInt(3);
			column	= itsColumnGenerator.nextInt(3);
			
			if(board.getGameModel(new GridPosition(row, column)) == null)
			{
				break;
			}
		}
		
		String descriptor = null;
		if(player.getId() == 1)
		{
			descriptor = new String("X");
		}
		else if(player.getId() == 2)
		{
			descriptor = new String("O");
		}
		
		return new TTTMove(row, column, descriptor);
	}

	
	private Random itsRowGenerator, itsColumnGenerator;
}
